using UnityEngine;
using System;
using UnityEngine.InputSystem;
using Unity.VisualScripting;
using UnityEngine.UI;
// 处理鼠标输入，控制相机旋转和攻击
public class MouseInputReader
{
    public PlayerInputControl playerInput;
    private Vector3 cameraRotation;
    public float translationMouseSpeed;
    public float verticalMouseSpeed;
    private GameObject gameObject;
    public bool isTab = true;
    public Image image;
    public Sprite sprite1, sprite2;
    private bool isSprite1 = true;
    public MouseInputReader(GameObject camera, float MouseSpeed, float verticalSpeed, GameObject GameObject)
    {
        playerInput = new PlayerInputControl();
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
        translationMouseSpeed = MouseSpeed;
        verticalMouseSpeed = verticalSpeed;
        gameObject = GameObject;
        onTabPressed();
        // playerInput.UI.alt.canceled += ctx => onTabPressed();
    }

    public void OnClick()
    {
        if (isSprite1)
        {
            image.sprite = sprite2;
            isSprite1 = false;
        }
        else
        {
            image.sprite = sprite1;
            isSprite1 = true;
        }
    }
    private void onTabPressed()
    {
        // 控制鼠标光标显示
        Cursor.visible = true;
        Cursor.lockState = CursorLockMode.None;
    }

    public void Update()
    {
    }


    public bool IsLeftClickPressed()
    {
        if (!isTab)
            return false;
        return playerInput.Attack.AttackClickAction.triggered;
    }


    public void OnEnable() => playerInput.Enable();
    public void OnDisable() => playerInput.Disable();

}